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RUUF9SQVdfUE9TVF9EQVRBOyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKCX0gZWxzZSBpZiAoc3RybGVuKCRIVFRQX1BPU1RfVkFSU1siaW5wdXQiXSk+MCkgeyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKCQkkaW5wdXQgPSBzdHJpcHNsYXNoZXMoJEhUVFBfUE9TVF9WQVJTWyJpbnB1dCJdKTsgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCgl9IGVsc2UgeyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKCQkkaW5wdXQgPSBpbXBsb2RlKCJcclxuIiwgZmlsZSgncGhwOi8vaW5wdXQnKSk7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAoJfQoKCSRzZXJ2ZXIgICAgPSAkX0dFVFsic2VydmVyIl07CgkkdXNlciAgICAgID0gJF9HRVRbInVzZXIiXTsKCSRwYXNzd29yZCAgPSAkX0dFVFsicGFzc3dvcmQiXTsKCSRkYXRhYmFzZSAg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mQgPSB0cnVlOwogICAgICAgICAgICB9CiAgICAgICAgfSAKICAgIAogICAgICAgIGlmICghICRmb3VuZCApCiAgICAgICAgewogICAgICAgICAgICAkbWVzc2FnZVtdID0gJ0FkZGluZyAnIC4gJG5hbWU7CiAgICAgICAgICAgICRyb290bm9kZSA9ICRkb20tPmRvY3VtZW50X2VsZW1lbnQgKCk7CiAgICAgICAgICAgICRkYXRhYmFzZSA9ICRkb20tPmNyZWF0ZV9lbGVtZW50ICgnZGF0YWJhc2UnKTsKICAgICAgICAgICAgJGRhdGFiYXNlLT5zZXRfYXR0cmlidXRlICgnbmFtZScsICRuYW1lKTsKICAgICAgICAgICAgJGRhdGFiYXNlLT5zZXRfYXR0cmlidXRlICgnc2VydmVyJywgJHNlcnZlcik7CiAgICAgICAgICAgICRkYXRhYmFzZS0+c2V0X2F0dHJpYnV0ZSAoJ3Bhc3N3b3JkJywgJHBhc3N3b3JkKTsKICAgICAgICAgICAgJGRhdGFiYXNlLT5zZXRfYXR0cmlidXRlICgndXNlcm5hbWUnLCAkdXNlcik7CiAgICAgICAgICAgICRyb290bm9kZS0+YXBwZW5kX2NoaWxkICgkZGF0YWJhc2UpOwogICAgICAgIH0gICAgICAgCiAgCiAgICAgICAgJGRvbS0+ZHVtcF9maWxlICgnYXBwbGljYXRpb24ueG1sJyk7CiAgICAgICAgICRtZXNzYWdlW10gPSAnU2F2ZSBhY3Rpb24gc3VjY2VlZGVkISc7CiAgICAgICAgcmV0dXJuIGltcGxvZGUgKCJcbiIsICRtZXNzYWdlKTsKCX0KICAgIHJldHVybiAnQ291bGQgbm90IG9wZW4gY29uZmlndXJhdGlvbiBmaWxlICcgLiAkcGF0aDsKfQoKIApmdW5jdGlvbiBQZXJzaXN0ICgkbmFtZSwgJHZhbHVlKQp7CiAgICBzZXRjb29raWUoJG5hbWUsICR2YWx1ZSwgdGltZSgpKzM2MDApOwoJcmV0dXJuICRuYW1lIC4gJyB3YXMgc2V0IHRvICcgLiAkdmFsdWU7C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gICAgICBpZiAoc3RhdGUgJiYgZGF0YWJhc2VzW2RibmFtZV0udGFibGVzW3RhYmxlXSkKICAgICAgICB7ICAKICAgICAgICAgICAgZGF0YWJhc2VzW2RibmFtZV0udGFibGVzW3RhYmxlXS5zZWxlY3RlZCA9IGNvbHVtbjsKICAgICAgICAgICAgZGF0YWJhc2VzW2RibmFtZV0uZ2V0b2JqZWN0ICh0YWJsZSk7CiAgICAgICAgfQogICAgICAgIG15LnNldG9iamVjdCAoIGNvbHVtbiApOwogICAgfQogICAgZWxzZSBpZiAocGF0dGVybj0vZGJvXC4oXHcrKVwuKFx3KykvLmV4ZWMoa2V5KSkKICAgIHsKICAgICAgICB2YXIgZGJuYW1lICAgPSBwYXR0ZXJuWzFdOwogICAgICAgIHZhciB0YWJsZSAgICA9IHBhdHRlcm5bMl07IAogICAgICAgIGlmIChzdGF0ZSAmJiBkYXRhYmFzZXNbZGJuYW1lXS50YWJsZXNbdGFibGVdKQogICAgICAgICAgICBkYXRhYmFzZXNbZGJuYW1lXS5nZXRvYmplY3QgKHRhYmxlKTsgCiAgICB9CiAgICBlbHNlIGlmIChwYXR0ZXJuPS9kYm9cLihcdyspLy5leGVjKGtleSkpCiAgICB7IAogICAgICAgIHZhciBkYm5hbWUgICA9IHBhdHRlcm5bMV07IAogICAgICAgIG15LnRhYmxlICAgICA9IG51bGw7CiAgICAgICAgaWYgKHN0YXRlICYmIGRhdGFiYXNlc1tkYm5hbWVdKQogICAgICAgIHsgIAoJCQlDb250cm9sbGVyLmRhdGFiYXNlbmFtZSA9IGRibmFtZTsKICAgICAgICAgICAgZGF0YWJhc2VzW2RibmFtZV0uZ2V0b2JqZWN0cygpOwogICAgICAgIH0gIAogICAgfQogICAgdHJlZWJhci5pbnZva2UoKTsgCn0KCi8qCiogVklFV1MKKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCnZhciB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dteXNxbF9lcnJvciddOwogICAgICAgIGh0bS5wdXNoICgnPHRhYmxlIHdpZHRoPTUwMCBiZ2NvbG9yPSIjRkZGRkNDIiBzdHlsZT0iYm9yZGVyOnNvbGlkIDFweCBncmF5Ij48dHI+PHRkPicpOwogICAgICAgIGh0bS5wdXNoICgnPGltZyBzcmM9IicrUElDX1JPT1QrJy93ZWJzZXJ2aWNlcy9pbWFnZXMvRW1ibGVtLWltcG9ydGFudC1yZWQucG5nIiBhbGlnbj1sZWZ0PicpOwogICAgICAgIGZvciAodmFyIGUgaW4gZXJyKQogICAgICAgIHsKICAgICAgICAgICAgIGY9ZG9tLmdldEVsZW1lbnRzQnlUYWdOYW1lIChlcnJbZV0pOwogICAgICAgICAgICAgZm9yICh2YXIgeD0wO3g8Zi5sZW5ndGg7eCsrKQogICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICBpZiAoZlt4XS5maXJzdENoaWxkKQogICAgICAgICAgICAgICAgICAgICBodG0ucHVzaCAoJzxiPicrZXJyW2VdKyc8L2I+OiA8Y29kZT4nK2ZbeF0uZmlyc3RDaGlsZC5ub2RlVmFsdWUrJzwvY29kZT48YnI+Jyk7CiAgICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGh0bS5wdXNoICgnPC90ZD48L3RyPjwvdGFibGU+Jyk7CiAgICAgICAgaHRtLnB1c2ggKCc8c21hbGwgc3R5bGU9Y29sb3I6Z3JheT5UaGUgcXVlcnkgcmV0dXJuZWQgYW4gZXJyb3IuIFBsZWFzZSBjaGVjayB5b3VyIFNRTCBzeW50YXggYW5kIHRyeSBhZ2Fpbi48L3NtYWxsPicpOwogICAgICAgIHJldHVybiBodG0uam9pbiAoJycpOwogICAgfSAgICAKICAgIAogICAgaWYgKENvbnRyb2xsZXIuaGFzYml0KCBDb250cm9sbGVyLmJpdHMuVEVYVE9VVFBVVCApKQogICAgewogICAgICAgIGh0bS5wdXNoICgnPHhtcD4nKTsKICAgICAgICBodG0ucHVzaCAoJyAjJy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lID0gY29sW2ldLmdldEF0dHJpYnV0ZSAoIm5hbWUiKTsKICAgICAgICAgICAgICAgICAgICBzaXplID0gY29sW2ldLmdldEF0dHJpYnV0ZSAoInNpemUiKTsKICAgICAgICAgICAgICAgICAgICB2YWx1ZSA9IGNvbFtpXS5maXJzdENoaWxkID8gY29sW2ldLmZpcnN0Q2hpbGQubm9kZVZhbHVlIDogTlVMTDsKICAgICAgICAgICAgICAgICAgICBpZiAoQ29udHJvbGxlci5oYXNiaXQoIENvbnRyb2xsZXIuYml0cy5URVhUT1VUUFVUICkpCiAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICBodG0ucHVzaCAocGFkICh2YWx1ZSwgc2l6ZSkgKyAnICcpOwogICAgICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgaHRtLnB1c2ggKCByZW5kZXIodmFsdWUsIG5hbWUsIHgpICk7CiAgICAgICAgICAgICAgICAgICAgfSAKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQoJCQlodG0ucHVzaCAoICc8L3RhYmxlPicgKTsKCQkJcmV0dXJuIGh0bS5qb2luICgnJyk7CgkJfQoJCiAgICAgICAgdmFyIHUsdW5kZXJsaW5lPVtyZXBlYXQgKCctJywgMTApICsgJyAnXTsKICAgICAgICBjb2w9cmVjb3Jkc1swXS5jaGlsZE5vZGVzOwogICAgICAgIGZvciAodmFyIGk9MDtpPGNvbC5sZW5ndGg7aSsrKQogICAgICAgIHsKICAgICAgICAgICAgaWYoY29sW2ldLm5vZGVOYW1lPT0nZmllbGQnKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBuYW1lID0gY29sW2ldLmdldEF0dHJpYnV0ZSAoIm5hbWUiKTsKICAgICAgICAgICAgICAgIHNpemUgPSBjb2xbaV0uZ2V0QXR0cmlidXRlICgic2l6ZSIpOwogICAgICAgICAgICAgICAgaWYgKENvbnRyb2xsZXIuaGFzYml0KCBDb250cm9sbGVyLmJpdHMuVEVYVE9VVFBVVCApKQogICAgICAgICAgICAgICAgeyAKICAgICAgICAgICAgICAgICAgICB1PXJlcGVhdCAoJy0nLCBzaXplKTsKICAgICAgICAgICAgICAgICAgICBodG0ucHVzaCAocGFkIChuYW1lKycoJytzaXplKycpJywgc2l6ZSkgKyAnICcpOwogICAgICAgICAgICAgICAgICAgIHVuZGVybGluZS5wdXNoIChwYWQodSwgc2l6ZSkgKyAnICcpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIGh0bS5wdXNoICgnPHRkIHN0eWxlPSJiYWNrZ3JvdW5kLWNvbG9yOiNlMGUwZTAiIG5vd3JhcCBjbGFzcz0iaGVhZGVyIj4nICsgbmFtZSArICcmbmJzcDs8L3RkPicpOwogICAgICAgICAgICAgICAgfSAKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICAKICAgICAgICBpZiAoQ29udHJvbGxlci5oYXNiaXQoIENvbnRyb2xsZXIuYml0cy5URVhUT1VUUFVUICkpCiAgICAgICAgewogICAgICAgICAgICBodG0ucHVzaCAobGYgKyB1bmRlcmxpbmUuam9pbiAoJycpICsgbGYpOyAKICAgICAgICB9CiAgICAgICAgZWxzZQogICAgICAgIHsKICAgICAgICAgICAgaHRtLnB1c2ggKCc8L3RyPicpOwogICAgICAgIH0gCiAgICAgICAgCiAgICAgICAgZm9yICh2YXIgeD0wO3g8cmVjb3Jkcy5sZW5ndGg7eCsrKQogICAgICAgIHsKICAgICAgICAgICAgcG9zID0geCsxK3BhcnNlSW50KHF1ZXJ5LnBvc2l0aW9uKQogICAgICAgICAgICByZW5kZXI9cG9zPT1xdWVyeS5zZWxlY3RlZD90b2lucHV0OnRvdmFsdWU7CiAgICAgICAgICAgIGlmIChDb250cm9sbGVyLmhhc2JpdCggQ29udHJvbGxlci5iaXRzLlRFWFRPVVRQVVQgKSkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgaHRtLnB1c2ggKCcgJyArIHBhZCAocG9zLnRvU3RyaW5nKCksIDkpICsgJyAnKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBlbHNlCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGh0bS5wdXNoICgnPHRyPjx0ZCBhbGlnbj1yaWdodCBzdHlsZT0iYmFja2dyb3VuZC1jb2xvcjojZTBlMGUwIiBjbGFzcz0iJysocG9zPT1xdWVyeS5zZWxlY3RlZD8nJzonaGVhZGVyJykrJyI+JyArIAogICAgICAgICAgICAgICAgICAgIHRleHRsaW5rKHBvcywnQ29udHJvbGxlci5xdWVyeWNvbGxlY3Rpb24uc2VsZWN0ZWQuc2VsZWN0KCcrcG9zKycpJykgKyAKICAgICAgICAgICAgICAgICAgICAnPC90ZD4nKTsKICAgICAgICAgICAgfSAKICAgICAgICAgICAgCiAgICAgICAgICAgIGNvbD1yZWNvcmRzW3hdLmNoaWxkTm9kZXM7CiAgICAgICAgICAgIGZvciAodmFyIGk9MDtpPGNvbC5sZW5ndGg7aSsrKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBpZihjb2xbaV0ubm9kZU5hbWU9PSdmaWVsZCcpCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgbmFtZSA9IGNvbFtpXS5nZXRBdHRyaWJ1dGUgKCJuYW1lIik7CiAgICAgICAgICAgICAgICAgICAgc2l6ZSA9IGNvbFtpXS5nZXRBdHRyaWJ1dGUgKCJzaXplIik7CiAgICAgICAgICAgICAgICAgICAgdmFsdWUgPSBjb2xbaV0uZmlyc3RDaGlsZCA/IGNvbFtpXS5maXJzdENoaWxkLm5vZGVWYWx1ZSA6IE5VTEw7CiAgICAgICAgICAgICAgICAgICAgaWYgKENvbnRyb2xsZXIuaGFzYml0KCBDb250cm9sbGVyLmJpdHMuVEVYVE9VVFBVVCApKQogICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgaHRtLnB1c2ggKHBhZCAodmFsdWUsIHNpemUpICsgJyAnKTsKICAgICAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgIGh0bS5wdXNoICggcmVuZGVyKHZhbHVlLCBuYW1lLCB4KSApOwogICAgICAgICAgICAgICAgICAgIH0gCiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKENvbnRyb2xsZXIuaGFzYml0KCBDb250cm9sbGVyLmJpdHMuVEVYVE9VVFBVVCApKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBodG0ucHVzaCAobGYpOyAKICAgICAgICAgICAgfQogICAgICAgICAgICBlbHNlCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGh0bS5wdXNoICgnPC90cj4nKTsKICAgICAgICAgICAgfSAKICAgICAgICB9CiAgICB9IGVsc2UgcmV0dXJuICdRdWVyeSByZXR1cm5lZCBubyByZWNvcmRzJzsKICAgIAogICAgaWYgKENvbnRyb2xsZXIuaGFzYml0KCBDb250cm9sbGVyLmJpdHMuVEVYVE9VVFBVVCApKQogICAgewogICAgICAgIGh0bS5wdXNoICgnPC94bXA+Jyk7CiAgICB9CiAgICBlbHNlCiAgICB7CiAgICAgICAgaHRtLnB1c2ggKCc8L3RhYmxlPicpOwogICAgfSAKICAgIHJldHVybiBodG0uam9pbiAoJycpOwp9KTsKCgp2YXIgYnVpbGRxdWVyeSA9IFZpZXcuY3JlYXRlICgnYnVpbGRxdWVyeScsICdxYmZpZWxkbGlzdCcsIGZ1bmN0aW9uICgpCnsgCiAgICB2YXIgaHRtPVtdLHF1ZXJ5PUNvbnRyb2xsZXIucXVlcnljb2xsZWN0aW9uLnNlbGVjdGVkOwogICAgaWYgKENvbnRyb2xsZXIuaGFzYml0KCBDb250cm9sbGVyLmJpdHMuQlVJ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V0QXR0cmlidXRlICgnZGF0YWJhc2UnKTsKICAgICAgICAgIAogICAgICAgIHZhciB0YWJsZSA9IGRvbS5nZXRFbGVtZW50c0J5VGFnTmFtZSAoJ3RhYmxlJyk7CiAgICAgIAogICAgICAgIGRvY3VtZW50LnRpdGxlID0gQVBQTElDQVRJT05fTkFNRSArICcgLSAnICsgbm9kZW5hbWU7CiAgICAgICAgZm9yICh2YXIgeD0wO3g8dGFibGUubGVuZ3RoO3grKykKICAgICAgICB7ICAKICAgICAgICAgICAgdGFibGVuYW1lID0gdGFibGVbeF0uZ2V0QXR0cmlidXRlICgnbmFtZScpCiAgICAgICAgICAgIGtleSAgPSBub2RlbmFtZSArICcuJyArIHRhYmxlbmFtZQogICAgICAgICAgICB0cmVlLmFkZCAodGFibGVuYW1lLCBrZXksIG5vZGVuYW1lKTsKICAgICAgICAgICAgdHJlZS5pdGVtc1trZXldLmljb249aW1hZ2VjcmVhdGUgKCcvd2Vic2VydmljZXMvaW1hZ2VzL2ljb19ncmlkLmpwZycpOwogICAgICAgICAgICB0cmVlLmFkZCAoJ2xvYWRpbmcuLi4nLCBrZXkgKyAnL3N1YicsIGtleSk7IAogICAgICAgICAgICBDb250cm9sbGVyLmRhdGFiYXNlc1sgQ29udHJvbGxlci5kYXRhYmFzZW5hbWUgXS50YWJsZXMgWyB0YWJsZW5hbWUgXSA9IAogICAgICAgICAgICAgICAgVGFibGUuY3JlYXRlKHRhYmxlW3hdLCBDb250cm9sbGVyLmRhdGFiYXNlc1sgQ29udHJvbGxlci5kYXRhYmFzZW5hbWUgXSk7IAogICAgICAgIH0KICAgICAgICBtYWluLmludm9rZSAoKTsKICAgIH0gICAgIAp9CgpDb250cm9sbGVyLm9udGFibGUgPSBmdW5jdGlvbiAoZGF0YSwgY2FsbGJhY2spCnsKIAogICAgdmFyIGRibmFtZSwgYXR0YWNoLCBjb2x1bW4sIG5hbWUsIGtleSwgZG9tPVhtbERvY3VtZW50LmNyZWF0ZSgpOyAgIAogICAgQ29udHJvbGxlci5xdWVyeWNvbGxlY3Rpb24uc2VsZWN0ZWQgPSBudWxsOwogICAgaWYgKGRvbS5sb2FkWE1MIChkYXRhKSkgIAogICAgeyAKICAgICAgICB2YXIgdGFibGVzICA9IGRvbS5nZXRFbGVtZW50c0J5VGFnTmFtZSAoJ3RhYmxlJyk7CiAgICAgICAgdmFyIGNvbHVtbnMgPSBkb20uZ2V0RWxlbWVudHNCeVRhZ05hbWUgKCdjb2x1bW4nKTsKICAgICAgICAgICAgIAogICAgICAgIGZvciAodmFyIHg9MDt4PHRhYmxlcy5sZW5ndGg7eCsrKQogICAgICAgIHsgIAogICAgICAgICAgICBkYm5hbWUgPSB0YWJsZXNbeF0uZ2V0QXR0cmlidXRlICgnZGF0YWJhc2UnKTsgCiAgICAgICAgICAgIG5hbWUgICA9IHRhYmxlc1t4XS5nZXRBdHRyaWJ1dGUgKCduYW1lJyk7CiAgICAgICAgfQogICAgICAgIAogICAgICAgIGF0dGFjaCA9ICdkYm8uJyArIGRibmFtZSArICcuJyArIG5hbWU7IAogICAgICAgIHRyZWUuaXRlbXNbYXR0YWNoXS5jbGVhcigpOyAKICAgICAgICAKICAgICAgICBkb2N1bWVudC50aXRsZSA9IEFQUExJQ0FUSU9OX05BTUUgKyAnIC0gJyArIGF0dGFjaDsKICAgICAgICBDb250cm9sbGVyLmRhdGFiYXNlbmFtZSAgICAgPSBkYm5hbWU7ICAgICAgCiAgICAgICAgQ29udHJvbGxlci50YWJsZSAgICAgICAgICAgICA9IENvbnRyb2xsZXIuZGF0YWJhc2VzW2RibmFtZV0udGFibGVzW25hbWVdOwogICAgICAgIENvbnRyb2xsZXIudGFibGUuY29sdW1ucyAgICAgPSBbXTsKICAgICAgICBmb3IgKHZhciB4PTA7eDxjb2x1bW5zLmxlbmd0aDt4KyspCiAgICAgICAgeyAgCiAgICAgICAgICAgIG5hbWUgICAgICAgPSBjb2x1bW5zW3hdLmdldEF0dHJpYnV0ZSAoJ25hbWUnKTsgCiAgICAgICAgICAgIGtleSAgICAgICAgPSBhdHRhY2ggKyAnLicgKyBuYW1lOwogICAgICAgICAgICBjb2x1bW4gICAgID0gQ29sdW1uLmNyZWF0ZShjb2x1bW5zW3hdLCBhdHRhY2gpOwogICAgICAgICAgICBkZXNjICAgID0gJzxiIGNsYXNzPXNtYWxsPicgKyBjb2x1bW4udHlwZSArIChjb2x1bW4uc2l6ZSYmY29sdW1uLnNpemUubGVuZ3RoPjA/JyAoJytjb2x1bW4uc2l6ZSsnKSc6JycpICsgJzwvYj4nOwogICAgICAgICAgICB0cmVlLmFkZCAobmFtZSArICcgJyArIGRlc2MsIGtleSwgYXR0YWNoKTsKICAgICAgICAgICAgdHJlZS5pdGVtc1trZXldLmljb249JzxpbWcgc3JjPSInICsgUElDX1JPT1QgKyAnL3dlYnNlcnZpY2VzL2ltYWdlcy9pLnMucHJvcGVydHkuZ2lmIiBhbGlnbj0iYWJzbWlkZGxlIj4nOwogICAgICAgICAgICBpZiAoY29sdW1uLmtleSAmJiBjb2x1bW4ua2V5Lmxlbmd0aCA+IDApIENvbnRyb2xsZXIudGFibGUua2V5ID0gbmFtZTsKICAgICAgICAgICAgQ29udHJvbGxlci50YWJsZS5jb2x1bW5zLnB1c2ggKCBjb2x1bW4gKTsKICAgICAgICB9CiAgICAgICAgaWYgKGNhbGxiYWNrICYmIHR5cGVvZihjYWxsYmFjayk9PSdmdW5jdGlvbicpIHJldHVybiBjYWxsYmFjaygpOwoJCW1haW4uaW52b2tlICgpOwogICAgfQp9CgpDb250cm9sbGVyLm9ub3BlbiA9IGZ1bmN0aW9uIChkYXRhKQp7IAogICAgdmFyIGF0dGFjaCwgbmFtZSwgZG9tPVhtbERvY3VtZW50LmNyZWF0ZSgpOyAgIAogICAgaWYgKGRvbS5sb2FkWE1MIChkYXRhKSkgIAogICAgeyAgCiAgICAgICAgQ29udHJvbGxlci5yZWNvcmRzZXQgPSBkb207CiAgICAgICAgcXVlcmllci5pbnZva2UgKCk7CiAgICB9Cn0KC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GF0YSkpICAKICAgIHsgICAKICAgICAgICB2YXIgbmFtZSwgdmFsdWUsIGFkZCA9IGRvbS5nZXRFbGVtZW50c0J5VGFnTmFtZSAoJ2FkZCcpOyAgIAogICAgICAgIGZvciAodmFyIHg9MDt4PGFkZC5sZW5ndGg7eCsrKQogICAgICAgIHsgIAogICAgICAgICAgICBuYW1lID0gYWRkW3hdLmdldEF0dHJpYnV0ZSAoJ25hbWUnKTsKICAgICAgICAgICAgaWYgKGFkZFt4XS5maXJzdENoaWxkKQogICAgICAgICAgICAgICAgY29va2llW25hbWVdPWFkZFt4XS5maXJzdENoaWxkLm5vZGVWYWx1ZTsKICAgICAgICB9ICAKICAgICAgICBpZiAoY29va2llLnZpZXdhcykgQ29udHJvbGxlci52aWV3YXMgPSBjb29raWUudmlld2FzOwogICAgICAgIGJlZ2luUmVuZGVyICgpIDsKICAgIH0gIAp9Ci8qCiogQ09OVFJPTExFUiBQUk9QRVJUSUVTCioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwpDb250cm9sbGVyLnF1ZXJ5Y29sbGVjdGlvbiA9IHsKICAgIGluZGV4IDogLTEsCiAgICBzZWxlY3RlZCA6IG51bGwsCiAgICBzZWxlY3QgOiBmdW5jdGlvbiAoeCkgeyB0aGlzLnNlbGVjdGVkPXg7bWFpbi5pbnZva2UoKTt9LAogICAgaXRlbXMgOiBbXSwKICAgIGtleXM6IHt9Cn0KQ29udHJvbGxlci5maXJzdGtleSAgICAgPSAwOwpDb250cm9sbGVyLmxhc3RrZXkgICAgICA9IDA7CkNvbnRyb2xsZXIua2V5cGFnZSAgICAgID0gW107CkNvbnRyb2xsZXIudGFibGUgICAgICAgID0gbnVsbDsKQ29udHJvbGxlci50YWJsZXMgICAgICAgPSB7fTsKQ29udHJvbGxlci5kYXRhYmFzZXMgICAgID0ge307CkNvbnRyb2xsZXIucGFnZXNpem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ZTsKICAgICAgICAgIHRoaXMucmVxdWVzdCA9IFdlYnNlcnZpY2UucG9zdCAodGhpcy5kYXRhYmFzZS5jcmVhdGVxdWVyeSAodGhpcy50ZXh0LCB0aGlzLnBvc2l0aW9uKSwgZnVuY3Rpb24gKGRhdGEsIGlkKQogICAgICAgICAgewogICAgICAgICAgICAgIHZhciBvPUNvbnRyb2xsZXIucXVlcnljb2xsZWN0aW9uLml0ZW1zOwogICAgICAgICAgICAgIGZvciAodmFyIHg9MDt4PG8ubGVuZ3RoO3grKykKICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgaWYgKGlkPT1vW3hdLnJlcXVlc3QpCiAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgdmFyIGRvbT1YbWxEb2N1bWVudC5jcmVhdGUoKTsgICAKICAgICAgICAgICAgICAgICAgICAgaWYgKGRvbS5sb2FkWE1MIChkYXRhKSkgIAogICAgICAgICAgICAgICAgICAgICB7ICAKICAgICAgICAgICAgICAgICAgICAgICAgIG9beF0ucmVzdWx0ID0gZG9tOwogICAgICAgICAgICAgICAgICAgICAgICAgQ29udHJvbGxlci5xdWVyeWNvbGxlY3Rpb24uaW5kZXggPSB4OwogICAgICAgICAgICAgICAgICAgICAgICAgQ29udHJvbGxlci5xdWVyeWNvbGxlY3Rpb24uc2VsZWN0ZWQgPSBvW3hdOwogICAgICAgICAgICAgICAgICAgICAgICAgcXVlcmllci5pbnZva2UgKCk7CiAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgfQogICAgICAgICAgfSk7CiAgICAgICB9CiAgICB9IAoJCglvLmtleSA9IGRhdGFiYXNlLm5hbWUgKyAnLicgKyBuYW1lOwoJcmV0dXJuIG87Cn0KCgpmdW5jdGlvbiBUYWJsZSAoKSB7fQpUYWJsZS5jcmVhdGUgPSBmdW5jdGlvbiAobm9kZSwgZGJvYmplY3QpCnsKCXZ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